import xadmin

from .models import *
from xadmin.views.website import LoginView


class StudentsAdmin(object):
    search_fields = ('name', 'class_name__class_name', 'subjects__name',)
    style_fields = {'subjects': 'checkbox-inline', }
    list_display = ('name', 'sex', 'age', 'address',)
    list_filter = ('sex',)
    # 顺序排序
    ordering = ('age', 'name',)

class ClassAdmin(object):
    list_display = ('class_name',)

class SubjectsAdmin(object):
    list_display = ('name', 'score',)

class TeachersAdmin(object):
    list_display = ('name',)



class LoginViewAdmin(LoginView):
    title = '学生信息管理系统'


xadmin.site.register(Teachers, TeachersAdmin)


xadmin.site.register(Subjects, SubjectsAdmin)

xadmin.site.register(Class, ClassAdmin)


xadmin.site.register(Students, StudentsAdmin)


xadmin.site.register(LoginView, LoginViewAdmin)


from xadmin.views import CommAdminView
class GlobalSetting(CommAdminView):
    # 左上角及浏览器标题
    site_title = '学生信息管理系统'
    # 页脚版权信息
    site_footer = 'Copyright © 2018 宝宝巴士'

    # 左侧边栏如果以后项目越来越多了，有一个归类会更好看些，也方便管理操作。
    menu_style = 'accordion'


xadmin.site.register(CommAdminView, GlobalSetting)